//
// Created by 黄扬航 on 2023/4/19.
//

#ifndef SNAKE_V1_00_POINT_H
#define SNAKE_V1_00_POINT_H

#include "Map.h"
#include <queue>
#include <iostream>
#include "Tools.h"

class Point
{
private:
    struct ItemInner
    {
        int X, Y;
        bool IsBorder, IsFood, IsSnake;
        int Heading; //(8上，5下，4左，6右)
    };
    Point()
    {
        Tools a;
        a.MoveCursorTo(80, 80, "Success");
        for (int i = 0; i < MaxLength; i++)
        {
            for (int j = 0; j < MaxWidth; j++)
            {  //y
                const int Index = i + j * MaxLength;
                if (j == 0 || j == MaxWidth - 1 || i == 0 || i == MaxLength - 1)
                {
                    PointItems[Index].IsBorder = true;
                }
                else
                {
                    PointItems[Index].IsBorder = false;
                }
                PointItems[Index].IsFood = false;
                PointItems[Index].IsSnake = false;
                PointItems[Index].X = i;
                PointItems[Index].Y = j;
            }
        }
    }
    static Point* Pointer;
public:
    std::queue<int> FoodTarget;
    static bool ThereIsFood;
    using Item = ItemInner;
    static Item PointItems[600];
    void CreatFood();
    static Point& getInstance() {
        if (Pointer == NULL)
        {
            Pointer = new Point();
        }
        else return *Pointer;
    }
    Item& operator[] (std::size_t index) {
        return PointItems[index];
    }
};

#endif //SNAKE_V1_00_POINT_H
